package newapproach.elements;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import newapproach.writer.CoutXmlElement;
import newapproach.writer.XmlElement;

import org.dom4j.Element;

public class YForm extends YElement{

	private List<YElement> yElements;

	public YForm(Element table) throws Exception {
		super(table);
		yElements = new ArrayList<YElement>(); 
		for(Iterator<Element> it =table.elementIterator(); it.hasNext();){
			Element element = it.next();
			YElement yElement = newYElement(element);
			yElements.add(yElement);
		}
	}



	@Override
	public XmlElement toJsp() {
		List<XmlElement> formXmlElements = new ArrayList<XmlElement>();
		for(YElement yElement : yElements){
			formXmlElements.add(yElement.toJsp());
		}
		Map<String,String> formAtt = new HashMap<String,String>();
		formAtt.put("method", "post");
		formAtt.put("commandName", "bean");
		XmlElement formJspElement = new XmlElement("form:form", formAtt, formXmlElements);
		return formJspElement;
	}

	@Override
	public String toBean() {
		// TODO Auto-generated method stub
		return null;
	}

}
